home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-06-09 | 5.0 KB | 199 lines | [TEXT/MPS ] |
- --
- -- © 1994, 1995 Art of Memory Ltd.
- -- All Rights Reserved
- --
- -- This file is supplied as part of the TextPak demonstration. You are only
- -- entitled to use this software to understand how the demonstration works.
- -- You may not duplicate, modify, reproduce or distribute this software in
- -- any form. If you wish to purchase a licence to use this software, please
- -- contact Art of Memory Ltd.
- --
-
- object GlossaryDatabase is MultimediaDatabase
-
- has
-
- ----------------------------------------------------------------------------------------------
- --
- -- DATA ACCESS METHODS
- --
- --
-
- -- Return a list (collection) of glossary entries whose names
- -- start with a given letter of the alphabet
- -- The search assumes the glossarties are in alphabetical
- -- order: once it has found one entry that starts with the
- -- correct name, it continues until it finds an entry with
- -- a non-correct initial letter and then ends the search.
- GetGlossaryList(firstLetter)
- firstLetter is? CHARACTER;
-
- use
- loopCount;
- nextGlossaryEntry;
- foundStart;
- foundEnd;
- registerSize;
-
- do
- if APPLICATION.MouseSpin <> void then
- APPLICATION.MouseSpin.Start();
- end;
-
- result := new COLLECTION;
-
- -- Convert the letter to lower case to ease matching
- firstLetter := FirstLetter.Lower();
-
- from
- loopCount := 1;
- foundStart := false;
- --foundEnd := false;
- registerSize := #self.Register;
- until (loopCount>registerSize) loop --or foundEnd loop
-
- nextGlossaryEntry := self.Register @ loopCount;
-
- if ((((nextGlossaryEntry.LowerCaseName) @ 1) - firstLetter)=0) then
- if (nextGlossaryEntry.TextPath @ 1)<>'+' then
- result.Append(nextGlossaryEntry);
- end;
- end;
-
- step
- loopCount := loopCount + 1;
- end;
-
- if APPLICATION.MouseSpin <> void then
- APPLICATION.MouseSpin.Stop();
- end;
- end;
-
-
- -- Find a glossary entry whose name is glossaryWord or which
- -- has glossaryWord on its synonym list. If there is no such
- -- entry, return void, otherwise return the entry itself
- FindGlossaryEntry(glossaryWord)
- glossaryWord is? STRING;
-
- use
- loopCount;
- innerLoop;
- nextGlossaryEntry;
- listSize;
- registerSize;
-
- do
-
- if APPLICATION.MouseSpin <> void then
- APPLICATION.MouseSpin.Start();
- end;
-
- glossaryWord := StringLibrary.LowerCase(glossaryWord);
-
- from
- loopCount := 1;
- registerSize := #self.Register;
- until (loopCount>registerSize) or (result<>void) loop
-
- nextGlossaryEntry := self.register @ loopCount;
-
- if StringLibrary.StringEqual(nextGlossaryEntry.lowerCaseName,glossaryWord) then
- result := nextGlossaryEntry;
- else
- listSize := #nextGlossaryEntry.LowerCaseSynonymList;
- if listSize>0 then
- from
- innerLoop := 1;
- until innerLoop>listSize loop
- if StringLibrary.StringEqual(nextGlossaryEntry.LowerCaseSynonymList @ innerLoop, glossaryWord) then
- result := nextGlossaryEntry;
- end;
- step
- innerLoop := innerLoop + 1;
- end;
- end;
- end;
-
- step
- loopCount := loopCount + 1;
- end;
-
- if result=void then
- UserTracer.AddTrace("Cannot find glossary entry " + glossaryWord);
- end;
-
- if APPLICATION.MouseSpin <> void then
- APPLICATION.MouseSpin.Stop();
- end;
- end;
-
-
- end;
-
-
- --
- -- AUTHOR: Dan Crow
- --
- -- DATE: 20/03/94
- --
- -- A glossaryComponent holds information about a single
- -- glossary entry
- class glossaryComponent is databaseComponent;
-
- has
-
- Name; -- The name (trigger word) of the glossary entry
- LowerCaseName; -- The glossary name converted to lower case
- SynonymList; -- List of synonyms for the glossary entry
- LowerCaseSynonymList; -- The synonym list converted to lower case
- TextPath; -- Name of text file containing the glossary text
- TechniqueLink; -- (Optional) Making of Glass technique to link to
-
- ParseComponentData(dataList)
- dataList is? COLLECTION;
-
- use
- synList;
- synListSize;
- loopCount;
-
- do
-
- self.Name := dataList @ 1;
- --DanDebug.ShowAlert("Parsing glossary entry with name=" + self.Name);
- --APPLICATION.Refresh();
- self.LowerCaseName := StringLibrary.LowerCase(self.Name);
- synList := dataList @ 2;
- --DanDebug.ShowAlert("Name=" + self.Name + " synList=<" + synList + ">");
-
- if synList<>void then
- self.SynonymList := StringLibrary.StringToList(synList,',');
- synListSize := #self.synonymList;
- from
- self.LowerCaseSynonymList := new COLLECTION;
- loopCount := 1;
- until loopCount>synListSize loop
- if (self.synonymList @ loopCount)<>void then
- self.LowerCaseSynonymList.Append(StringLibrary.LowerCase(self.synonymList @ loopCount), loopCount);
- end;
- step
- loopCount := loopCount + 1;
- end;
- else
- self.SynonymList := new COLLECTION;
- self.LowerCaseSynonymList := new COLLECTION;
- end;
-
- self.TextPath := dataList @ 3;
-
- -- If there is a fourth list item, its the Making of Glass
- -- technique to link to
- self.TechniqueLink := void;
- if #dataList>3 then
- if (dataList @ 4) is? STRING then
- self.TechniqueLink := dataList @ 4;
- end;
- end;
- end;
- end;